<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>键值比较大</title>
    <style>
        * {
            font-size: 28px;
        }
    </style>
</head>

<body>
    <button type="button" id="btnAdd">添加</button>
    <button type="button" id="btnGet">取值</button>
    <script>
        const str = Array.from({ length: 5 * 1024 * 1023 }, _ => "哦").join('')
        btnAdd.onclick = function () {
            console.time(`存长度${str.length}`)
            localStorage.setItem('_', str)
            console.timeEnd(`存长度${str.length}`)
        }
        btnGet.onclick = function () {
            console.time(`取长度${str.length}`)
            localStorage.getItem('_')
            console.timeEnd(`取长度${str.length}`)
        }
    </script>
</body>

</html>